Skip to content

IBFlex: Import Flex Queries via HTTP API#5352

Open
lmb wants to merge 2 commits intoportfolio-performance:masterfrom
lmb:ibflex-web-service-update
Open

IBFlex: Import Flex Queries via HTTP API#5352
lmb wants to merge 2 commits intoportfolio-performance:masterfrom
lmb:ibflex-web-service-update

Conversation

@lmb
Copy link
Contributor

@lmb lmb commented Jan 19, 2026

This is an implementation of the Flex Web Service API to automatically fetch Flex Queries. Please see the individual commit descriptions for details.

Disclosure: I used Claude Code to draft this PR and have done manual code review on it. I think the code is OK, maybe a bit verbose. Please let me know if I've missed something or if I can somehow remove some code.

Fixes: #5246

lmb added 2 commits January 18, 2026 20:45
IBKR allows retrieving preconfigured Flex Queries via a rudimentary HTTP interface.
Doing so requires a query ID which identifies the Flex Query, and a secret token.
The secret token can be obtained from the web interface an expires after a while.

Add a new menu item which allows importing from such a Flex Web Service. This saves
users from logging in, manually selecting the query, executing it, etc. Credentials
like query ID and the secret token are stored in the .portfolio file. This means that
copying the file elsewhere will retain that information. The user is warned about this
on the settings screen.
The Flex Web Service always runs a Flex Query with a fixed date range configured when
creating the query. This means that we can't choose what date range to fetch.
The easiest thing for the user is to configure the query with the maximum duration
(currently 365 days). The downside of this is that it populates the import wizard with
a lot of duplicate items after the first import.

Filter extracted items to exclude ones we've likely already imported based on the
transaction date. The user can clear the date we're using for this via the settings
dialog.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IB Flex: automatically fetch flex queries via web api

1 participant